package synapses;

import java.util.Random;

import signal.SignalInterface;
import neurons.NeuronInterface;

public class FromExteriorSynapse extends SynapseAbstract {

	private NeuronInterface neuronOut;
	private double weight;

	public FromExteriorSynapse(NeuronInterface neuron) {
		neuron.growIncomingSynapse(this);
		neuronOut = neuron;
		weight = Math.random();
		charged = false;

	}

	public FromExteriorSynapse(NeuronInterface neuronOut,
			SynapseInterface synapseOut) {
		neuronOut.growIncomingSynapse(this);
		this.neuronOut = neuronOut;

	}

	@Override
	public void transmit(SignalInterface whatIDeliver) {
		data = whatIDeliver.getData();
		charged = true;
		System.out
				.println(toString() + " stocking : " + whatIDeliver.getData());
		if (neuronOut != null) {
			neuronOut.aSynapseHasBeenCharged(this);
		}

	}

	@Override
	public Double getWeight() {

		return weight;
	}

}
